#ifndef ZLMEDIAKIT_DBRECORD_H
#define ZLMEDIAKIT_DBRECORD_H

#include "sqlite3.h"
#include "sqlite3pp.h"
#include <memory>
#include <string>

namespace mediakit {

class DbRecord {
public:
    struct Mp4Item {
        std::string file;
        uint64_t start;
        uint64_t end;
    };

public:
    static DbRecord &Instance();
    bool Init(const std::string &path);
    bool AddTable(const std::string &stream_id);
    bool AddRecord(const std::string &stream_id, uint64_t start, uint64_t end, const std::string &path);
    std::vector<std::shared_ptr<DbRecord::Mp4Item>> Query(const std::string &stream_id, uint64_t start, uint64_t end);
    bool Remove(const std::string &stream_id, const std::string &path);

private:
    std::shared_ptr<sqlite3pp::database> _db = nullptr;
    DbRecord() = default;
    bool init = false;
};

} // namespace mediakit

#endif